<!DOCTYPE html>
<html lang="en">
<html lang="zh-cn" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=OMWGedRBKY5sj2ujkdcxqffdRg85SKoz"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="js/jquery.js"></script>
    <script src="js/pintuer.js"></script>
    <script src="/js/vuejs-2.5.16.js"></script>
    <script src="/js/axios-0.18.0.js"></script>
    <script src="/js/laydate/laydate.js"></script>
    <script src="/element-ui/lib/index.js"></script>
    <title>根据经纬度定位</title>
    <style>
        html, body, #allmap{
            width: 100%;
            height: 100%;
            padding: 0;
            margin: 0;
            overflow: hidden;
        }
        #result{
            padding: 7px 10px;
            position: fixed;
            top: 10px;
            left: 20px;
            width: 450px;
            background: #fff;
            box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
            border-radius: 7px;
            z-index: 99;
        }
        #result input{
            width:130px;
            margin-right:10px;
            height:25px;
            border: 1px solid rgba(27, 142, 236, 0.5);
            border-radius: 5px;
        }
        #result button{
            border: 1px solid rgba(27, 142, 236, 0.5);
            border-radius: 5px;
            background: rgba(27, 142, 236, 0.5);
            color: #fff
        }
    </style>
</head>
<body>
<div id='allmap'></div>

<div id='result'>
    <img v-bind:src="avatar" width="70">
    <div style="color: red"> 姓名 :{{name}}</div><tr/>
    <tr/>
    经度: <input id="lng" type="text"  v-model="x"/><tr/>
    纬度: <input id="lat" type="text" v-model='y'/>
    <button onclick="theLocation()"/>查询</button>
</div>
<script>
    // 百度地图API功能
    var map = new BMapGL.Map("allmap");
    map.centerAndZoom(new BMapGL.Point(116.331398,39.897445),11);
    map.enableScrollWheelZoom(true);

    // 用经纬度设置地图中心点
    function theLocation(){
        if(document.getElementById("lng").value != "" && document.getElementById("lat").value != ""){
            map.clearOverlays();
            var new_point = new BMapGL.Point(document.getElementById("lng").value,document.getElementById("lat").value);
            var marker = new BMapGL.Marker(new_point);  // 创建标注
            map.addOverlay(marker);              // 将标注添加到地图中
            map.panTo(new_point);
        }
    }
</script>

<script type="text/javascript">
    const app = new Vue({
        el:'#result',
        data:{
            x:'110',
            y:'99',
            name:'',
            gender:'',
            address:'',
            avatar:''
        },
        methods:{
            findById(id){
                axios.get("/baidu/?userId="+id).then(resp=>{
                              this.x =resp.data.x
                              this.y =resp.data.y
                              this.name =resp.data.nickname
                              this.gender =resp.data.gender
                              this.address =resp.data.Address
                              this.avatar =resp.data.avatar


                })
            }

        },
        created(){
            let id=location.search.split("=")[1]
            this.findById(id)

        }
    })
</script>
</body>
</html>